package com.hmdp.config;

import io.lettuce.core.RedisClient;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author TJS
 * @Description
 * @create 2023/1/4 21:48
 */
@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        /*
            useSingleServer()表示单节点。
            集群模式下，config.useClusterServers()可设置多个节点
         */
        config.useSingleServer().setAddress("redis://124.70.110.9:6379").setPassword("123456");
        return Redisson.create(config);
    }
    /*
        Redisson.create();无参
        public static RedissonClient create() {
            Config config = new Config();
            config.useSingleServer().setAddress("redis://127.0.0.1:6379");
            return create(config);
        }
        默认本地连接，无密码
     */
}
